<?php
namespace catchAdmin\shopping\tables\forms;

use think\facade\Request;
use catcher\library\form\Form;
use app\common\model\ShoppingClassify as ClassifyModel;

class ShoppingClassify extends Form
{
    public function fields(): array
    {
        $request = Request::instance();
        $serviceAddress = $request->domain();
        // TODO: Implement fields() method.
        return [
            self::input('name', '名称')->required()->col(12),
            self::cascader('parent_id', '父级分类', [])->options(
                ClassifyModel::where('parent_id', 0)->field(['id', 'name', 'parent_id'])
                    ->select()->toTree()
            )->col(12)->props(self::props('name', 'id', [
                'checkStrictly' => true
            ]))->filterable(true)->clearable(true)->style(['width' => '100%']),

            self::image('图片', 'image')->action($serviceAddress.'/upload/image'),
            self::number('sort', '排序')->value(1)->col(12),
        ];
    }
}